// pages/accept/accept.js
Page({

    /**
     * 页面的初始数据
     */
    data: {
        name: '',
        id:0,
        sessionID:'',
        hiddenmodalput:true,
        work:"",
        projectId:'',
        chuangNum:""
    },
    //得到输入的分工
    getWork(e){
      this.setData({
        work:e.detail.value
      })
      console.log("work",this.data.work)
    },
    //取消
    modalinput(e){
      this.setData({
        hiddenmodalput:true
      })
    },
    //确认
    confirm(e){
      this.setData({
        hiddenmodalput:true
      })
      wx.request({
        url: 'https://www.hschuangsai.com/message/reply',
        data: {
          "id": this.data.id,
          "reason": "",
          "status": "ACCEPT"
        },
        header: {
          'content-type': 'application/json',
          'session': this.data.sessionID
        },
        method: "POST",
        success: (result) => {
          if(result.data.code != 0){
            wx.showToast({
              title: result.data.commonErrorCode.errorSuggestion,
              icon:'none'
            })
          }else{
            console.log('同意入队')
            wx.showToast({
              title: '操作成功',
            })
          }
        }
      })
      wx.request({
        url: 'https://www.hschuangsai.com/member/work',
        data: {
          memberChuangNum: this.data.chuangNum,
          projectId: this.data.projectId,
          work: this.data.work,
        },
        header: {
          'content-type': 'application/json',
          'session': this.data.sessionID
        },
        method: "POST",
        success: (result) => {
          
        },
      })
      wx.switchTab({
        url: '/pages/project/project',
      })
    },

    
// 点击确认按钮触发的事件
    gotoApplication(e){
      this.setData({
        hiddenmodalput:false
      })
    },

    gotoDetail(e){
        wx.redirectTo({
          url: '/pages/project/applicationInDetail/applicationInDetail?messageId='+this.data.id+'&status=0',
        })
    },

    /**
     * 生命周期函数--监听页面加载
     */
    onLoad: function (options) {
      this.setData({
        id: options.messageId,
        name: options.name,
        sessionID:wx.getStorageSync('sessionID'),
        projectId:options.projectId,
        chuangNum:options.chuangNum
      })
        
    }

})